﻿@model DataSharing.Models.Product
@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

<fieldset>
    <legend>Cập nhật sản phẩm</legend>
    <form action="/ProductManager/Index" method="post">
        
        <div class="row">
            <div class="col-md-6">
                <div>Id</div>
                <input name="Id" value="@Model.Id" class="form-control" />
            </div>
            <div class="col-md-6">
                <div>Name</div>
                <input name="Name" value="@Model.Name" class="form-control" />
            </div>
        </div>

        <div class="row">
            <div class="col-md-6">
                <div>Unit Price</div>
                <input name="UnitPrice" value="@Model.UnitPrice" class="form-control" />
            </div>
            <div class="col-md-6">
                <div>Image</div>
                <input name="Image" value="@Model.Image" class="form-control" />
            </div>
        </div>

        <div class="row">
            <div class="col-md-6">
                <div>Quantity</div>
                <input name="Quantity" value="@Model.Quantity" class="form-control" />
            </div>
        </div>

        <div class="row">
            <div class="col-md-12">
                <button onclick="form.action='/ProductManager/Insert'" class="btn btn-default">Insert</button>
                <button onclick="form.action='/ProductManager/Update'" class="btn btn-default">Update</button>
                <a href="/ProductManager/Delete/@Model.Id" class="btn btn-default">Delete</a>
                <a href="/ProductManager/Index" class="btn btn-default">Reset</a>
            </div>
        </div>

    </form>
</fieldset>

<fieldset>
    <legend>Danh sách sản phẩm</legend>
    <table class="table">
        <tr>
            <th>Id</th>
            <th>Name</th>
            <th>Unit Price</th>
            <th>Quantity</th>
            <th>Image</th>
            <th></th>
        </tr>
        @foreach (var p in ViewBag.Products)
        {
            <tr>
                <td>@p.Id</td>
                <td>@p.Name</td>
                <td>@p.UnitPrice</td>
                <td>@p.Quantity</td>
                <td>@p.Image</td>
                <td>
                    <a href="/ProductManager/Edit/@p.Id">Edit</a>
                </td>
            </tr>
        }
    </table>
</fieldset>

